#ifndef FORMATCHANGE_H
#define FORMATCHANGE_H

#include <QTextCharFormat>
#include "Change/change.h"

class FormatChange : public Change
{
public:
	FormatChange();
	FormatChange(int newRev, int newUser, int newDoc, int newPos, int newNum);
	FormatChange(QByteArray bytes);

	QByteArray toBytes();				//convert the change into a byte array

	bool isEmpty();		//checks if any properties have been set

	//get functions - for properties
	int getNum() {return num;}
	QFont::Weight getBold() {return bold;}
	bool getItalics() {return italics;}
	bool getUnderline() {return underline;}
	int getFontSize() {return fontSize;}
	QString getFontFamily() {return fontFamily;}
	QRgb getForeColour() {return foreColour;}
	QRgb getBackColour() {return backColour;}
	Qt::Alignment getAlign() {return align;}
	int getList() {return list;}

	//get functions - for <property>Changed
	bool getBoldChanged() {return boldChanged;}
	bool getItalicsChanged() {return italicsChanged;}
	bool getUnderlineChanged() {return underlineChanged;}
	bool getFontSizeChanged() {return fontSizeChanged;}
	bool getFontFamilyChanged() {return fontFamilyChanged;}
	bool getForeColourChanged() {return foreColourChanged;}
	bool getBackColourChanged() {return backColourChanged;}
	bool getAlignChanged() {return alignChanged;}
	bool getListChanged() {return listChanged;}

	//set functions
	void setNum(int newNum) {num = newNum;}
	void setBold(int newBold);
	void setItalics(bool newItalics);
	void setUnderline(bool newUnderline);
	void setFontSize(int newFontSize);
	void setFontFamily(QString newFontFamily);
	void setForeColour(QRgb newForeColour);
	void setBackColour(QRgb newBackColour);
	void setAlign(Qt::Alignment newAlign);
	void setList(int newList);

private:
	void init();

	enum formatType {BOLD, ITALICS, UNDERLINE, FONT_SIZE, FONT_FAMILY, FORE_COLOUR, BACK_COLOUR, LIST, ALIGN};

	int num;	//the number of chars this applies to (ie/ the selection)

	//the properties
	QFont::Weight bold;
	bool italics;
	bool underline;
	int fontSize;
	QString fontFamily;
	QRgb foreColour;
	QRgb backColour;
	Qt::Alignment align;
	int list;

	//if the property was changed and if we need to send it
	bool boldChanged;
	bool italicsChanged;
	bool underlineChanged;
	bool fontSizeChanged;
	bool fontFamilyChanged;
	bool foreColourChanged;
	bool backColourChanged;
	bool alignChanged;
	bool listChanged;
};

#endif // FORMATCHANGE_H
